﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hospital.BLL.IBLL;

namespace Hospital.Web
{
    public partial class Index : System.Web.UI.Page
    {
        #region Member
        private IAnnouncementService announcementService;
        #endregion

        #region Property
        public IAnnouncementService AnnouncementService
        {
            set { announcementService = value; }
            get { return announcementService; }
        }
        #endregion

        #region Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadAnnouncement();
            }
        }
        #endregion

        #region Function
        private void LoadAnnouncement()
        {
            IList<Hospital.Model.Announcement> announceList = announcementService.GetAnnouncement(6);
            StringBuilder sbAnnounce = new StringBuilder();
            foreach (Hospital.Model.Announcement announce in announceList)
            {
                sbAnnounce.AppendFormat("<a href='AnnouncementDetail.aspx?Id={0}'>{1}<br/>{2}</a><br/>",
                    announce.Id, announce.PublishDate.ToString("yyyy-MM-dd"), announce.Title);
            }
            lAnnouncement.Text = sbAnnounce.ToString();
        }
        #endregion
    }
}
